<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
    <c:set var="ctx" value="${pageContext.request.contextPath}" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>金融机构详情</title>
    <jsp:include page="../../import.jsp" flush="true" />
    <script language="javascript"  src="<%=path %>/resource/utils/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <div tabid="tabA" title="基本信息" lselected="true">
            <form id="formSet1">
            	<div class="fieldset1 tabel_col clearFix">
					<div class="caption">
                        <span class="title">基本信息</span>
                    </div>
					<div class="fieldBox col_33">
						<div class="label">金融机构名称</div>
						<div class="field">
							<input name=""  value="${friVo.fundRasInsNm }" type="text" class="ui-textbox" readonly > 
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">统一社会信用代码<span class="requiredSymbol">*</span></div>
						<div class="field">
							<input name="uscc" id="uscc" type="text" value="${friVo.uscc }" class="ui-textbox" validate="{required:true}">
							
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">注册时间<span class="requiredSymbol">*</span></div>
						<div class="field">
							<input name="regCapTm" id="regCapTm" type="text" class="Wdate" onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 00:00:00',autoPickDate:true})" validate="{required:true}" >
						</div>
					</div>
					<div class="fieldBox col_66">
						<div class="label">注册地址<span class="requiredSymbol">*</span></div>
						<div class="field">
							<input name="regAddr" id="regAddr" type="text" class="ui-textbox"  validate="{required:true}" value="${friVo.regAddr}">
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">注册资金<span class="requiredSymbol">*</span></div>
						<div class="field">
							<input type="text" id="regCapAmt" name="regCapAmt" class="ui-textbox" value="${friVo.regCapAmt}" validate="{required:true,number:true}" />
						     <select name="regCapUntCd" id="regCapUntCd" ligerui="width: 60" data-value="${friVo.regCapUntCd}">
								<c:forEach items="${capUntCdList }" var="kv" begin="0" step="1" varStatus="status">
									<c:if test="${status.index == 0}">
								    	<option value="${kv.key }" checked >${kv.value }</option>
									</c:if>
								    <c:if test="${status.index != 0}">
								    	<option value="${kv.key }">${kv.value }</option>
								 	</c:if>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="fieldBox col_66_auto">
						<div class="label">区域<span class="requiredSymbol">*</span></div>
						<div class="field">
							<!-- <input name="rgnPrCd" id="rgnPrCd" type="text" class="ui-textbox" value=""> -->
							<jsp:include page="../../system/sysRegion/region.jsp"
										 flush="true">
								<jsp:param name="regionShowLvl" value="2" />
							</jsp:include>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">机构属性<span class="requiredSymbol">*</span></div>
						<div class="field">
							<select name="fundInsProp" id="fundInsProp">
								<c:forEach items="${fundInsPropList }" var="propItem">
									<option value="${propItem.key }" <c:if test="${friVo.fundInsProp== propItem.key }"> selected </c:if> >${propItem.value }</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">机构类型<span class="requiredSymbol">*</span></div>
						<div class="field">
							<select name="fundInsType" id="fundInsType"   >
								<option value="">请选择</option>
								<c:forEach items="${fundInsTypeList}" var="typeItem">
									<option value="${typeItem.key }"  <c:if test="${friVo.fundInsType== typeItem.key }"> selected </c:if> >${typeItem.value }</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">合作时间<span class="requiredSymbol">*</span></div>
						<div class="field">
							<input name="coopTm" id="coopTm" type="text" class="Wdate" onClick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 00:00:00',autoPickDate:true})" validate="{required:true}"  >
						</div>
					</div>
					<div class="fieldBox col_33">
						<div class="label">融担公司企业编号</div>
						<div class="field">
							<input name="guaranteeCoopNum" id="guaranteeCoopNum" type="text" class="ui-textbox"   value="${friVo.guaranteeCoopNum}">
						</div>
					</div>
					<div class="fieldBox col_100">
						<div class="label">备注</div>
						<div class="field" style="width: 90%;">
                        	<textarea name="remark" id="remark" rows="4"  validate="{required:false,maxlength:300}" class="l-textarea" style="width:99%"  >${friVo.remark }</textarea>
						</div>
					</div>
				</div>
				<div class="sqPanel">
	                <div class="sqPanel_head inL">
	                    <div class="btnsBox inLC">
	                    	<span id="spl_rl_add_btn" class="sq-button sq-button-round" onclick="friRlPsnAddBtnEvent();">添加</span>
	                    </div>
	                    <span>主要人员信息</span>
	                </div>
	                <div class="sqPanel_body">
	                    <div id="ligergrid_A1" class="sq-grid"></div>
	                </div>
	            </div>
	            <div class="btnsBox">
	                <c:if test="${empty friVo.audStsCd  || friVo.audStsCd==0 }">
	          			<span  id="startFlowBtn" class="sq-button sq-button-round" onclick="startFlowAcc(${id});" >发起流程  </span>
	          		</c:if>
	          		<span id="saveBtn1" class="sq-button sq-button-round" onclick="updateFundInfo(${id});">保存</span>
                    <input name="friBaseId" id="friBaseId" type="hidden" value="${id }">
	            </div>
            </form>
        </div>
        <div tabid="tabB" title="备案资料">
            <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
        </div>
    </div>
</div>


<script type="text/javascript">
    var loadedTabs=[];
    var friRlPsnGrid;
    var friBaseId = '${id}';
    var isRlpsn = '${isRlpsn}';

    $(function(){
    	
        var formSet1  = $("#formSet1").ligerForm({
            validate : true
        });
        $("#formSet1").ligerForm();

        formSet1.setFieldValidate("rgnProvCd", {
            required: true,
            select: false
        });
    	formSet1.setFieldValidate("rgnCityCd", {
            required: true,
            select: false
        });
    	formSet1.setFieldValidate("fundInsType", {
            required: true,
            select: true
        });
        
        initTab();
        initFriBaseRlGrid();
        if(isRlpsn!=null && isRlpsn!='' && isRlpsn>0){
        }else{
        	addfriRlPsnFix();
        }
        var regCapTmStr='${friVo.regCapTmStr}';
        if(regCapTmStr !='' && null!= regCapTmStr && 'undefined' != regCapTmStr ){//初始化注册时间 
        	regCapTmStr = new Date(regCapTmStr);
             regCapTmStr = DateUtils.formatDate(regCapTmStr, DateUtils.YYYY_MM_DDHHMMSS);
             $("#regCapTm").val(regCapTmStr);
        }
        var coopTmStr='${friVo.coopTmStr}';
        if(coopTmStr !='' && null!= coopTmStr && 'undefined' != coopTmStr ){//初始化 合作时间
        	coopTmStr = new Date(coopTmStr);
            coopTmStr = DateUtils.formatDate(coopTmStr, DateUtils.YYYY_MM_DDHHMMSS);
            $("#coopTm").val(coopTmStr); 
        }
		//区域处理 rgnProvCd rgnCityCd rgnPrCd 
	    var rgnPrCd = '${friVo.rgnPrCd}';
	    var rgnCyCd = '${friVo.rgnCyCd}';
	    console.log("rgnPrCd"+rgnPrCd);
	    console.log("rgnCyCd"+rgnCyCd);
	    if(rgnPrCd !='' && null!= rgnPrCd && 'undefined' != rgnPrCd ){//初始化 区域 省
            setRgnProvCdUpdataValue(rgnPrCd);
        }
	    if(rgnCyCd !='' && null!= rgnCyCd && 'undefined' != rgnCyCd ){//初始化 区域 市
            setRgnCityCdUpdataValue(rgnCyCd);
        }
	    setRegionSelectDataChange();
        
        
        
    })
    //设置页面数据
    function setData(data){
        var form = liger.get("formSet1");
		/* /* //区域数据处理
        setRgnProvCdUpdataValue(data.rgnPrCd);
        setRgnCityCdUpdataValue(data.rgnCyCd);
        setRegionSelectDataChange(); */
    };

    //初始化Tab页
    function initTab(){
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: 450,
            onBeforeSelectTabItem: function (tabid) {
                var _friBaseId = $("#friBaseId").val();
                if(tabid!="tabA"){
                    if(!_friBaseId){
                        top.$.ligerDialog.SQalert({content: "请确认金融机构基本信息已存在", SQ_type: "warning"});
                        return false;
                    }
                }
            },
            onAfterSelectTabItem: function(tabid) {
                if (loadedTabs.indexOf(tabid)<0) {
                    var _friBaseId = $("#friBaseId").val();
                    if(tabid!="tabA"){
                        if(!_friBaseId){
                            top.$.ligerDialog.SQalert({content: "请确认金融机构基本信息已存在", SQ_type: "warning"});
                            return false;
                        }
                    }
                    loadedTabs.push(tabid);
                    switch (tabid){
                     	case "tabB": //备案资料
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/rfbase/fribaseinfo/recordInfo.do?friId="+_friBaseId);                     		
                     	break;
                    }
                };
                SetIframe_height();
            }
        });
    };
    
  	//证件类型
    var certTypCdListJSON = [];
    <c:if test="${not empty certTypCdListJSON}"> certTypCdListJSON = ${certTypCdListJSON}; </c:if>

	//联系人类型
    var rlTypCDListJSON = [];
    <c:if test="${not empty rlTypCDListJSON}"> rlTypCDListJSON = ${rlTypCDListJSON}; </c:if>
 
    //联系人类型
    var mustAddRlPsnJSON = [];
    <c:if test="${not empty mustAddRlPsnTypCdJSON}">
    	mustAddRlPsnJSON = ${mustAddRlPsnTypCdJSON};
    	console.log("mustAddRlPsnJSON ==="+JSON.stringify(mustAddRlPsnJSON));
    </c:if>

	//初始化主要人员信息
    function initFriBaseRlGrid() {
    	var _friBaseId = $("#friBaseId").val();
        friRlPsnGrid = $("#ligergrid_A1").ligerGrid({
            url: '<%=path%>/rfbase/fribaseinfo/initRlPsnList.do?',
	    	method : 'get',
	    	parms:{"fund_id":_friBaseId},
	    	async: false,
	    	columns: [
					{ display: '联系人姓名(<span class="c_red">*</span>)', name: 'rlNm', width: 150, editor: {type: 'text'},
                        validate: function (value,rowData,col) {
                            if (StringUtils.isEmpty(value)) return "此项为必填项！";
                        },maxlength: 50, min:1     // 最大长度
					},
	  	            { display: '联系人类型(<span class="c_red">*</span>)', name: 'rlTypCd', width: 200,
						editor: {
	                       type: 'select',
	                       isShowCheckBox: true, isMultiSelect: true,
	                       data: rlTypCDListJSON,
	                       valueField: 'key',
	                       textField: 'value',
						},
						valueField: 'rlTypCd',
						textField: 'rlTypCdNm',
						render: function (item) {
							
							return item.rlTypCdNm;
						},
						validate: function (value) {
						  if (StringUtils.isEmpty(value)) return "此项为必填项！";
						}
	  	            },
	  	           {display: '股比',name:'stockRatio',width:100,editor: {type: 'text'}},
	  	           { display: '证件类型(<span class="c_red">*</span>)', name: 'certTypCd', width: 140,
						editor: {
	                       type: 'select',
	                       data: certTypCdListJSON,
	                       valueField: 'key',
	                       textField: 'value'
						},
	                   	valueField: 'certTypCd',
	                   	textField: 'certTypCdNm',
	                   	render: function (item) {
	                   	    return item.certTypCdNm;
	                  	},
                        validate: function (value,rowData,col) {
                            if (StringUtils.isEmpty(value)) return "此项为必填项！";
                        }
	  	            },
	  	            { display: '证件号', name: 'certNo', width: 170, editor: {type: 'text'},
                        validate: function (value,rowData,col) {
                        },digits: true,maxlength: 20, min:15
                    },
	                { display: '联系电话(<span class="c_red">*</span>)', name: 'tel', width: 150, editor: {type: 'text'},
                        validate: function (value,rowData,col) {
                            if (StringUtils.isEmpty(value)) return "此项为必填项！";
                        },digits: true,maxlength: 20, min:8
					},
	   	  	        { display: '操作', minWidth: 80 , align:'left',
		            	render: function (rowdata, rowindex, value){
		                	var d = "";
                             if (rowdata.id) {
                                 d = '<a class="sq-button-hasicon" href="javascript:deleteDB(';
                                 d += "'" + rowdata.rlTypCd + "'";
                                 d += ",'" + rowdata.id + "'";
                                 d += ')"><i class="sqBtnIco_7"></i>删除</a>';
                             }else{
                            	 	if(rowindex==0){
	                           	  		} else{
	                           		 	d='<a class="sq-button-hasicon" href="javascript:deletePage(';
	 									d+="'"+rowdata.__id+"'";
	 									d+=')"><i class="sqBtnIco_7"></i>删除</a>';
	                           	  	} 
								}
		                    return d;
		            	}
					}],
	   	  	   usePager: false,
	           root: 'rows',
	           record: 'total',
	           hideLoadButton: true,
	           width: '100%',
	           height: 300,
	           heightDiff: -2,
			   enabledEdit: true,
	           isScroll: false,
	           checkbox: false,
	           rownumbers: true,
	           allowUnSelectRow: true,
	           alternatingRow: false,
	           enabledSort:false,
	           onBeforeSubmitEdit: function (e) {
	           },
	           onBeforeEdit: function (e) {
	           	//新增加一行联系人类型不允许修改
           		if (e.column.columnname == "rlTypCd" && e.record.rlTypCd=='1' && e.rowindex==0) {
           			 if(e.record.id){
           				e.column.editor.readonly=false; 
           			 }else{
           				 e.column.editor.readonly=true;
           			 }
	               }else{
	            	   e.column.editor.readonly=false; 
	               }
	           },
	           onAfterShowData: function() {
	           	SetIframe_height ();
	           }
	        });
	    };

    //修改联系人信息为isdel=1
    function deleteDB(rowdata_id, _id) {
    	
    	var rlPsnJson=friRlPsnGrid.getData();
    	
    	if(rlPsnJson.length<=1){
    		$.ligerDialog.SQalert({content: "请至少保留一行主要人员信息!",SQ_type: "warning"});
    		return ;
    	}
    	//删除此条联系人信息
        $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
            if (flag == false) return;
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: {"rl_psn_id": _id},
                url: '<%=path%>/rfbase/fribaseinfo/updateRlPsnbyId.do?',
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        friRlPsnGrid.reload();
                    } else {
                        $.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        });
    }

    //本地删除
    function deletePage(rowdata_id) {
        $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
            if (flag == false) return;
            //删除页面
            friRlPsnGrid.deleteRow(rowdata_id);
        })
    }

    //联系人新增
    function friRlPsnAddBtnEvent() {
        var manager = $("#ligergrid_A1").ligerGetGridManager();
        manager.addRow({
            rlNm: '',
            rlTypCd: '',
            certTypCd: '0',
            certTypCdNm:"身份证",
            certNo: '',
            tel: '',
            rlRem: ''
        });
    };
  //联系人新增固定联系人
    function addfriRlPsnFix() {
        var manager = $("#ligergrid_A1").ligerGetGridManager();
        manager.addRow({
            rlNm: '',
            rlTypCd: '1',
            rlTypCdNm: '联系人',
            certTypCd: '0',
            certTypCdNm:"身份证",
            certNo: '',
            tel: '',
            rlRem: '',ligerIndex:0
        });
    };
  //修改保存金融机构详情
    function updateFundInfo(_fundId){
    	
    	
	  if(StringUtils.isEmpty(_fundId)) return;
    	
    	var url = '<%=path%>/rfbase/fribaseinfo/saveFundDetail.do';
    	var ligerForm = liger.get("formSet1");
    	var data = ligerForm.getData();
    	if (!ligerForm.valid()) {
	    	$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning",SQ_showButtons: true});
            return false ; 
     	}
    	var isValid = SQ.validGrid('ligergrid_A1');
        if (isValid == false) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
            return false;
        }
    	
    	var rgnProvCd = $('#rgnProvCd').val();
    	var rgnCityCd = $('#rgnCityCd').val();
    	console.log(rgnProvCd+"tyep"+typeof rgnProvCd);
    	if(rgnProvCd =='' || null== rgnProvCd || 'undefined' == rgnProvCd ){
    		 top.$.ligerDialog.SQalert({content:"区域-省 不能为空!", SQ_type: "warn"});
    		 return false ; 
    	}
    	if(rgnCityCd =='' || null== rgnCityCd || 'undefined' == rgnCityCd ){
    		$.ligerDialog.SQalert({content:"区域-市 不能为空!", SQ_type: "warn"});
	   		 return false ; 
   		}
    	var fundInsType = $('#fundInsType').val();
    	console.log(fundInsType);
    	if(fundInsType == "" || null == fundInsType || 'undefined' == fundInsType ){
    		$.ligerDialog.SQalert({content:"机构类型不能为空!", SQ_type: "warn"});
	   		 return false ; 
    	}
    	//注册时间不能为空
    	var regCapTm = $('#regCapTm').val();
    	if(regCapTm == "" || null == regCapTm || 'undefined' == regCapTm){
    		$.ligerDialog.SQalert({content:"注册时间不能为空!", SQ_type: "warn"});
	   		 return false ; 
    	}
    	//合作时间不能为空
    	var coopTm = $('#coopTm').val();
    	if(coopTm == "" || null == coopTm || 'undefined' == coopTm){
    		$.ligerDialog.SQalert({content:"合作时间不能为空!", SQ_type: "warn"});
	   		 return false ; 
    	}
    	
    	var rlPsnJson=friRlPsnGrid.getData();
    	if(rlPsnJson.length==0){
    		$.ligerDialog.SQalert({content: "请添加一行主要人员信息!",SQ_type: "warning"});
    		return ;
    	}
    	var isLink =false;//联系人类型
		var isNot =false;//法人代表
		for(var p in rlPsnJson){//遍历json数组时，这么写p为索引，0,1
			var rlTypCdStr=rlPsnJson[p].rlTypCd;
			//请至少添加一行联系人信息
			if(rlTypCdStr.indexOf("1")>=0){//当联系人类型为联系人
				isLink=true;
			}
			//联系人证件号非必填 当结构类型命中：1-工商企业、2-银行 、3-小额贷款公司、4-事业单位情况下；法人代表姓名必填
			if(fundInsType =='1' || fundInsType =='2' || fundInsType=='3' || fundInsType=='4'){	
				if(rlTypCdStr.indexOf("2")>=0){//当联系人类型为法人代表
					isNot=true;
				}
	    	}else{
				isNot=true;
			}
		}
    	if(!isNot){
    		$.ligerDialog.SQalert({content: "请添加法人代表人员信息",SQ_type: "warning"});
    		return ;
    	}
    	if(!isLink){
			$.ligerDialog.SQalert({content: "请添加联系人人员信息",SQ_type: "warning"});
			return ;
		} 
		
    	data["friRlPsnGrid"] = JSON.stringify(friRlPsnGrid.getData());
    	data["coopTm"] =coopTm;//合作时间
    	data["regCapTm"] =regCapTm;//注册时间
    	data["id"]=_fundId;
    	var wait_dialog;
        $.ajax({
    		type: 'post',
    		dataType:'json',
    		data: data,
    		url: url,
    		beforeSend: function(){
    	          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
    	     },
    		success:function(msg){
    			 wait_dialog.close();
    			 if(msg.success == 1){
    				 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
    				 window.location.reload();
    				/* //回调刷新列表
    		        var callback = GET_W2Wcallback();
    		        callback(); */
    			 }else{
    				 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
    			 }
    		}
    	});
    }
	//发起卓远担保新业务评审流程
	function startFlowAcc(_fundId){
		//校验一下必填项
		var ligerForm = liger.get("formSet1");
    	var data = ligerForm.getData();
    	if (!ligerForm.valid()) {
	    	$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning",SQ_showButtons: true});
            return false ; 
     	}
    	var isValid = SQ.validGrid('ligergrid_A1');
        if (isValid == false) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
            return false;
        }
    	
    	var rgnProvCd = $('#rgnProvCd').val();
    	var rgnCityCd = $('#rgnCityCd').val();
    	console.log(rgnProvCd+"tyep"+typeof rgnProvCd);
    	if(rgnProvCd =='' || null== rgnProvCd || 'undefined' == rgnProvCd ){
    		 top.$.ligerDialog.SQalert({content:"区域-省 不能为空!", SQ_type: "warn"});
    		 return false ; 
    	}
    	if(rgnCityCd =='' || null== rgnCityCd || 'undefined' == rgnCityCd ){
    		$.ligerDialog.SQalert({content:"区域-市 不能为空!", SQ_type: "warn"});
	   		 return false ; 
   		}
    	var fundInsType = $('#fundInsType').val();
    	console.log(fundInsType);
    	if(fundInsType == "" || null == fundInsType || 'undefined' == fundInsType ){
    		$.ligerDialog.SQalert({content:"机构类型不能为空!", SQ_type: "warn"});
	   		 return false ; 
    	}
    	//注册时间不能为空
    	var regCapTm = $('#regCapTm').val();
    	if(regCapTm == "" || null == regCapTm || 'undefined' == regCapTm){
    		$.ligerDialog.SQalert({content:"注册时间不能为空!", SQ_type: "warn"});
	   		 return false ; 
    	}
    	//合作时间不能为空
    	var coopTm = $('#coopTm').val();
    	if(coopTm == "" || null == coopTm || 'undefined' == coopTm){
    		$.ligerDialog.SQalert({content:"合作时间不能为空!", SQ_type: "warn"});
	   		 return false ; 
    	}
    	
    	var rlPsnJson=friRlPsnGrid.getData();
    	if(rlPsnJson.length==0){
    		$.ligerDialog.SQalert({content: "请添加一行主要人员信息!",SQ_type: "warning"});
    		return ;
    	}
    	var isLink =false;//联系人类型
		var isNot =false;//法人代表
		for(var p in rlPsnJson){//遍历json数组时，这么写p为索引，0,1
			var rlTypCdStr=rlPsnJson[p].rlTypCd;
			//请至少添加一行联系人信息
			if(rlTypCdStr.indexOf("1")>=0){//当联系人类型为联系人
				isLink=true;
			}
			//联系人证件号非必填 当结构类型命中：1-工商企业、2-银行 、3-小额贷款公司、4-事业单位情况下；法人代表姓名必填
			if(fundInsType =='1' || fundInsType =='2' || fundInsType=='3' || fundInsType=='4'){	
				if(rlTypCdStr.indexOf("2")>=0){//当联系人类型为法人代表
					isNot=true;
				}
	    	}else{
				isNot=true;
			}
		}
    	if(!isNot){
    		$.ligerDialog.SQalert({content: "请添加法人代表人员信息",SQ_type: "warning"});
    		return ;
    	}
    	if(!isLink){
			$.ligerDialog.SQalert({content: "请添加联系人人员信息",SQ_type: "warning"});
			return ;
		} 
		//校验结束
		data["friRlPsnGrid"] = JSON.stringify(friRlPsnGrid.getData());
    	data["coopTm"] =coopTm;//合作时间
    	data["regCapTm"] =regCapTm;//注册时间
    	data["id"]=_fundId;
		//先保存
		  $.ajax({
    		type: 'post',
    		dataType:'json',
    		data: data,
    		url: "<%=path%>/rfbase/fribaseinfo/saveFundDetail.do",
    		beforeSend: function(){
    	          wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
    	     },
    		success:function(msg){
    			 if(msg.success == 1){
    				 $("#startFlowBtn").hide();
    			    	$.ajax({
    			    		type: 'post',
    			    		dataType:'json',
    			    		data:{
    			    			id:_fundId
    			    		},
    			    		url: '<%=path%>/rfbase/fribaseinfo/addFlowStartForGuarantee.do',
    						success : function(msg) {
    							wait_dialog.close();
    							if (msg.success == 1) {
    								UIUtils.alertSuccessHold1(msg.info);
    								frameElement.dialog.close();
    							} else {
    								UIUtils.alertErrorHold1(msg.info);
    							}
    						}
    					});
    			 }else{
    				 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
    			 }
    		}
    	});
		
	}
</script>



</body>
</html>
